<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>语法补充1</title>
</head>
<body>
    <script>
        {
            //扩展运算
            let arr1=[1,2,3,4,5];
            console.log(...arr1);
            console.log(Math.max(...arr1));
            let arr2=[6,7,8,9,10];
            let nArr=[...arr1,...arr2];
            console.log(nArr);
            let obj1={name:"zhangsan",age:20,sex:1}
            let obj2={grade:96}
            let nObj={...obj1,...obj2};
            console.log(nObj);
        }
        {
            //解构赋值
            let arr1=[1,2,3];
            let [a,b,c]=arr1;
            console.log(a,b,c);
            let arr2=[1,2,3,4,5];
            [a,b,...c]=arr2;
            console.log(a,b,c);
            let x=1,y=2;
            console.log(x,y);
            [x,y]=[y,x];
            console.log(x,y);
            let obj={name:"zhangsan",age:20,sex:1};
            let{name:n,age,sex}=obj;
            console.log(n,age,sex);
            function fn1(...arr) {
                arr.forEach((o)=>{console.log(o)})
            }
            fn1(1,2,3,5,8);
            function fn2() {
                return {name:"zs",sNum:1203}
            }
            let{name,sNum:s}=fn2();
            console.log(name,s);
            function fn3({name,sex}) {
                console.log(name,sex)
            }
            let obj2={name:"zhangsan",sex:20};
            fn3(obj2);
        }
    </script>
</body>
</html>